<template>
	<view style="width: 100%;">
<!-- 		<u-field v-model="specialty" :auto-height="false" maxlength="500" :border-bottom="false" type="textarea" label=" " :fixed="true" label-width="0"  :clearable="false"
		placeholder="你可以通过描述你擅长的东西，也可以简单的介绍一 下，说说你的求职目标。"/> -->
		<textarea maxlength="-1" style="width: 100%; padding: 20rpx 30rpx; box-sizing: border-box;" @input="handleInput" :value="specialty" placeholder="你可以通过描述你擅长的东西，也可以简单的介绍一 下，说说你的求职目标。" />
		<view style="margin: 32rpx 32rpx 0;">
			<u-button shape="circle" :disabled="disabled" type="primary" @click="handleSubmit">
				保存
			</u-button> 
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	import http from '@/utils/http'
	import api from '@/api'
	export default {
		name: 'EditSpecialty',
		data() {
			return {
				specialty: '',
				specialty2: '',
				disabled:false
			} 
		},
		created() {
			this.initData(this.basicStore)
		},
		computed: {
			basicStore() {
				return this.$store.state.resume.basic
			}
		},
		methods: {
			handleInput(e){
				this.specialty2 = e.detail.value
			},
			// 初始化接口返回数据
			initData(interfaceBasic) {
				this.specialty = interfaceBasic.specialty
				this.specialty2 = interfaceBasic.specialty
				console.log(this.specialty,'this.specialty')
			},
			// 保存
			handleSubmit() {
				this.specialty = this.specialty2
				if (!this.specialty) {
					this.$refs.uTips.show({
						title: '请填写自我描述',
						type: 'error'
					})
					return false
				}
				this.disabled = true
				http
					.post(api.resume_specialty_save, {
						specialty: this.specialty
					})
					.then(res => {
						if (parseInt(res.data.code) === 200) {
							this.$refs.uTips.show({
								title: res.data.message,
								type: 'success'
							})
							setTimeout(()=>{
								uni.navigateBack({
									delta:1
								})
								this.specialty = ''
								this.specialty2 = ''
							},1500)
						} else {
							this.$refs.uTips.show({
								title: res.data.message,
								type: 'error'
							})
						}
						this.disabled = false 
					})
					.catch(err => {
						console.log(err)
					})
			}
		}
	}
</script>

<style lang="scss" scoped></style>
